Skip to content

Add non-flash SDPA path gated by ET_USE_UNFUSED_SDPA#18717

Open
kimishpatel wants to merge 1 commit into
gh/kimishpatel/237/basefrom
gh/kimishpatel/237/head
Open

Add non-flash SDPA path gated by ET_USE_UNFUSED_SDPA#18717
kimishpatel wants to merge 1 commit into
gh/kimishpatel/237/basefrom
gh/kimishpatel/237/head

Conversation

@kimishpatel

@kimishpatel kimishpatel commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Benchmarks show ET's flash attention is 10-12% slower than non-tiled
GEMM-based SDPA for decode (SeqLen=1) due to within-head tiling overhead
(multiple small GEMMs + online softmax rescaling). This adds an alternative
non-flash code path that computes full Q@K^T, standard softmax, then
scores@V using two GEMM calls, gated by #ifdef ET_USE_UNFUSED_SDPA so it
can be tested without disrupting the existing flash path.

The new cpu_sdpa function reuses existing SeqDim, stride extraction,
cpublas::gemm, and parallel_for infrastructure. Float-only (no quantized
input support). Threading granularity is one (batch, head) per work unit.

Differential Revision: D99677685

Benchmarks show ET's flash attention is 10-12% slower than non-tiled
GEMM-based SDPA for decode (SeqLen=1) due to within-head tiling overhead
(multiple small GEMMs + online softmax rescaling). This adds an alternative
non-flash code path that computes full Q@K^T, standard softmax, then
scores@V using two GEMM calls, gated by #ifdef ET_USE_UNFUSED_SDPA so it
can be tested without disrupting the existing flash path.

The new cpu_sdpa function reuses existing SeqDim, stride extraction,
cpublas::gemm, and parallel_for infrastructure. Float-only (no quantized
input support). Threading granularity is one (batch, head) per work unit.

Differential Revision: [D99677685](https://our.internmc.facebook.com/intern/diff/D99677685/)

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Apr 6, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18717

Note: Links to docs will display an error until the docs builds have been completed.

❌ 126 New Failures, 1 Unrelated Failure

As of commit 867ba3e with merge base fb1618e (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 6, 2026
@kimishpatel

Copy link
Copy Markdown
Contributor Author

submitted by accident, not meant to land immedidately

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions Bot added the Stale PRs inactive for over 60 days label Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported Stale PRs inactive for over 60 days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant